#include "sdlshowbmpthread.h"
#include <SDL2/SDL.h>


#define END(conditon,func) if(conditon) { \
        qDebug() << #func << "error" << SDL_GetError();\
        goto end;\
    }

SDLShowBMPThread::SDLShowBMPThread(QObject *parent) : QThread(parent)
{
    connect(this,&QThread::finished,this,&QThread::deleteLater);
}

SDLShowBMPThread::~SDLShowBMPThread()
{

    disconnect();

    requestInterruption();

    quit();

    wait();

    qDebug() << "SDLShowBMPThread" << "destroy";
}

void SDLShowBMPThread::run()
{

    int res = 0;

    const char* bmp_path = "/Users/apple/Documents/ffmpeg/qt/image/demo.bmp";

    SDL_Surface* surface = nullptr;

//    END(SDL_Init(SDL_INIT_VIDEO),SDL_Init);
    res = SDL_Init(SDL_INIT_VIDEO);


    qDebug() << res;

    return;
    surface = SDL_LoadBMP(bmp_path);

    END(!surface,SDL_LoadBMP);

    qDebug() << surface->w;

end:
    SDL_Quit();


}



